﻿using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.ADF.BaseClasses;
using System.Drawing;
using ZJGIS.Layout;
using ESRI.ArcGIS.Controls;
using PlanningGIS.Framework;

namespace PlanningGIS.Cartographic
{
    //自定义范围打印按钮
    //原有的普通打印功能按Arcmap的操作模式开发，用户提出该模式不能准确定义打印出图范围
    //自定义范围打印可以让用户以拉框的方式输入自定义的打印范围，并按照指定的比例尺获页面大小输出
    internal class PrintbyCustomArea : BaseDrawRectTool
    {
        IApplication m_Application = null;
        public PrintbyCustomArea()
        {
            base.m_caption = "自定义范围打印";
            base.m_toolTip = base.m_caption;
            m_cursor = System.Windows.Forms.Cursors.Cross;
        }
      
        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;
            base.OnCreate(hook);
        }

        public override void OnClick()
        {
            base.OnClick();
            (m_Application as IFramework).Tool = this;
        }

        public override void OnMouseUp(int button, int shift, int x, int y)
        {

            base.OnMouseUp(button, shift, x, y);

            //弹出自定义范围打印设置窗体，传入但前地图控件与用户输入的打印范围对象
            FrmCustomPrintSetting thisFrm = new FrmCustomPrintSetting();
            thisFrm.MapControlOutProp = (m_Application as IFramework).MapControl;
            thisFrm.PrintAreaProp = m_geom.Envelope;
            thisFrm.ShowDialog();
        }

        public override void OnMouseMove(int button, int shift, int x, int y)
        {
            base.OnMouseMove(button, shift, x, y);
            (m_Application as IFramework).MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
        }

        public override bool Enabled
        {
            get
            {
                return (m_Application as IFramework).IsMapCtrlactive ? true : false;
            }
        }
    }
}
